<template>
    <CodeEditor ref="Editor" />
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import CodeEditor from './CodeEditor/index.vue'

import TestCode from './Test.txt?raw';
import TestCode2 from './Test2.txt?raw';
const Editor = ref();

const SetValue = (TestCode: string) => {
    var CodeMapping: Record<string, string> = {};
    var CodeStr: string[] = TestCode.split('<<$$$@#*^^^|||PageSegmentation|||^^^*#@$$$>>');
    for (let i = 0; i < CodeStr.length; i++) {
        const _code = CodeStr[i].split('<<$$^^|^^$$>>');
        CodeMapping[_code[0]] = _code[1];
    };
    Editor.value.SetCode(CodeMapping);
}

onMounted(() => {
    SetValue(TestCode);
    setTimeout(() => {
        SetValue(TestCode2);
    }, 5000);
})

</script>
<style lang="less" scoped>

</style>